package com.csk.zsk.compents.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.csk.zsk.commons.entity.IdEntity;
import com.google.common.collect.Lists;

@Entity
@Table(name = "MUSIC")
// 此annoation为了截断对象的循环引用.
@JsonIgnoreProperties({ "rankingLists" })
public class Music extends IdEntity {

	private String songName;
	private String singerName;
	private String mp3url;
	private String lrc;
	private String musicLabel;
	private String albumName;
	private String albumUrl;
	private String singer_type;
	private String year;
	private Date time;
	private List<RankingList> rankingLists = Lists.newArrayList();

	public String getSongName() {
		return songName;
	}

	public void setSongName(String songName) {
		this.songName = songName;
	}

	public String getSingerName() {
		return singerName;
	}

	public void setSingerName(String singerName) {
		this.singerName = singerName;
	}

	public String getMp3url() {
		return mp3url;
	}

	public void setMp3url(String mp3url) {
		this.mp3url = mp3url;
	}

	public String getLrc() {
		return lrc;
	}

	public void setLrc(String lrc) {
		this.lrc = lrc;
	}

	public String getMusicLabel() {
		return musicLabel;
	}

	public void setMusicLabel(String musicLabel) {
		this.musicLabel = musicLabel;
	}

	public String getAlbumName() {
		return albumName;
	}

	public void setAlbumName(String albumName) {
		this.albumName = albumName;
	}

	public String getAlbumUrl() {
		return albumUrl;
	}

	public void setAlbumUrl(String albumUrl) {
		this.albumUrl = albumUrl;
	}

	public String getSinger_type() {
		return singer_type;
	}

	public void setSinger_type(String singer_type) {
		this.singer_type = singer_type;
	}

	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	// 多对多定义
	@ManyToMany
	// 中间表定义,表名采用默认命名规则
	@JoinTable(name = "MUSIC_LIST", joinColumns = { @JoinColumn(name = "MUSIC_ID") }, inverseJoinColumns = { @JoinColumn(name = "LIST_ID") })
	// Fecth策略定义
	@Fetch(FetchMode.SUBSELECT)
	// 集合按id排序.
	@OrderBy("id")
	public List<RankingList> getRankingLists() {
		return rankingLists;
	}

	public void setRankingLists(List<RankingList> rankingLists) {
		this.rankingLists = rankingLists;
	}

}
